package com.link.base.base.codereview.controller;

import com.link.base.base.codereview.model.SysCodeReviewApproveInfo;
import com.link.base.base.codereview.service.SysCodeReviewApproveInfoService;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.model.BasicModel;
import com.link.core.basic.query.QueryParams;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;


/**
 * 代码审核历史-
 *
 * @author 谢鑫
 * @date 2019/09/25 09:58
 */
@Controller
@RequestMapping("/link/sysCodeReviewApproveInfo")
public class SysCodeReviewApproveInfoController extends BasicController<SysCodeReviewApproveInfo> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private SysCodeReviewApproveInfoService sysCodeReviewApproveInfoService;

    @Override
    public BasicService<SysCodeReviewApproveInfo> getBasicService() throws Exception {
        return sysCodeReviewApproveInfoService;
    }

    @RequestMapping(value = "/approval", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> approval(@JsonParam SysCodeReviewApproveInfo sysCodeReviewApproveInfo, @JsonParam QueryParams qps) {
        Map<String, Object> result = new HashMap<String, Object>(4);
        try {
            BasicModel.transformClass(sysCodeReviewApproveInfo, qps);
            sysCodeReviewApproveInfoService.approval(sysCodeReviewApproveInfo);
            result.put("success", true);
//            result.put("result", directoryTree);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
